package com.boxin.ims.modules.sys.scheduler;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.boxin.framework.base.utils.DateUtils;
import com.boxin.ims.modules.momarketing.entity.QRCode;
import com.boxin.ims.modules.wechat.entity.LotteryRecord;
import com.boxin.ims.modules.wechat.entity.MemberLottery;
import com.boxin.ims.modules.wechat.score.service.ExchangeRecordService;
import com.boxin.ims.modules.wechat.service.LotteryRecordService;
import com.boxin.ims.modules.wechat.service.MemberLotteryService;
import com.boxin.ims.modules.wechat.service.SeckillGainerService;
import com.boxin.ims.modules.wechat.service.WechatDaoHelper;
import com.thinkgem.jeesite.modules.sys.entity.User;


@Service
public class ConsumeDataScheduler extends  AbstractScheduler {
	
	
	private String day = DateUtils.getLastDayString();
	
	@Autowired
	private LotteryRecordService lotteryRecordService;
	
	@Autowired
	private SeckillGainerService seckillGainerService;
	
	@Autowired
	private ExchangeRecordService exchangeRecordService;
	

	@Autowired
	private WechatDaoHelper wechatDaoHelper;
	
	@Autowired
	private MemberLotteryService memberLotteryService;

	@Override
	public String frequency() {
		return this.getSchedulerInfo().getFrequence();
	}

	
	
	@Override
	public void process()  {
		 Map<String , Object> params =new HashMap<String, Object>();
		 params.put("update_time", new Date(System.currentTimeMillis()));
		wechatDaoHelper.cleanMemberLotteryByToday(params);
		//1.核销    LotteryRecord  奖品
		  
		  Map<String , Object> params1 =new HashMap<String, Object>();
		  
		  params1.put("award_type", "会员抽奖");
		  params1.put("source_type", 1);
		  params1.put("update_time", new Date(System.currentTimeMillis()));
		  params1.put("day", DateUtils.getTodayString());
		wechatDaoHelper.queryLotteryRecordBYSourceType(params1);
		Map<String , Object> params2 =new HashMap<String, Object>();
		params2.put("award_type", "商家抽奖");
		params2.put("source_type", 2);
		 params2.put("update_time", new Date(System.currentTimeMillis()));
		 params2.put("day", DateUtils.getTodayString());
		wechatDaoHelper.queryLotteryRecordBYSourceType(params2);
		
		  Map<String , Object> params3 =new HashMap<String, Object>();
		params3.put("award_type", "会员注册礼品");
		params3.put("source_type", 3);
		 params3.put("update_time", new Date(System.currentTimeMillis()));
		 params3.put("day", DateUtils.getTodayString());
		wechatDaoHelper.queryLotteryRecordBYSourceType(params3);
		
		Map<String , Object> params8 =new HashMap<String, Object>();
		params8.put("award_type", "赞助奖品");
		params8.put("source_type", 4);
		params8.put("update_time", new Date(System.currentTimeMillis()));
		params8.put("day", DateUtils.getTodayString());
		wechatDaoHelper.queryLotteryRecordBYSourceType(params8);
			
		Map<String , Object> params9 =new HashMap<String, Object>();
		params9.put("award_type", "广告奖品");
		params9.put("source_type", 5);
		params9.put("update_time", new Date(System.currentTimeMillis()));
		params9.put("day", DateUtils.getTodayString());
		wechatDaoHelper.queryLotteryRecordBYSourceType(params9);
		
		Map<String , Object> params10 =new HashMap<String, Object>();
		params10.put("award_type", "砸金蛋");
		params10.put("source_type", 6);
		params10.put("update_time", new Date(System.currentTimeMillis()));
		params10.put("day", DateUtils.getTodayString());
		wechatDaoHelper.queryLotteryRecordBYSourceType(params10);
		
		Map<String , Object> params11 =new HashMap<String, Object>();
		params11.put("award_type", "推荐人送奖品");
		params11.put("source_type", 7);
		params11.put("update_time", new Date(System.currentTimeMillis()));
		params11.put("day", DateUtils.getTodayString());
		wechatDaoHelper.queryLotteryRecordBYSourceType(params11);
		
		
		//2.核销    积分兑换 exchangeRecord
		  Map<String , Object> params4 =new HashMap<String, Object>();
		  params4.put("update_time", new Date(System.currentTimeMillis()));
		  params4.put("day", DateUtils.getTodayString());
		wechatDaoHelper.queryExchangeRecord(params4);
		//3.核销    转发朋友圈  		ShareCircle
		  Map<String , Object> params5 =new HashMap<String, Object>();
		  params5.put("update_time", new Date(System.currentTimeMillis()));
		  params5.put("day", DateUtils.getTodayString());
		wechatDaoHelper.queryShareBYWin(params5);
		
		//4.核销    秒杀    SeckillGainer	//
		  Map<String , Object> params6 =new HashMap<String, Object>();
		  params6.put("update_time", new Date(System.currentTimeMillis()));
		  params6.put("day", DateUtils.getTodayString());
		wechatDaoHelper.querySeckillGainer(params6);
		
		//5.核销优惠券  wp_Coupon
		  Map<String , Object> params7 =new HashMap<String, Object>();
		  params7.put("update_time", new Date(System.currentTimeMillis()));
		  params7.put("day", DateUtils.getTodayString());
		wechatDaoHelper.queryCoupon(params7);
		
		System.out.println("本轮任务执行完毕...");
	}



	public String getDay() {
		return day;
	}



	public void setDay(String day) {
		this.day = day;
	}
	
	
	
	

}
